package com.lincoln.jenkins.test.deals;

import lombok.Data;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

@Data
public class ReceiveVerifyMsgDeal implements Deal {
    private long id;
    private String ticket;
    private String fromUsername;
    private String encryptUsername;
    private String fromNickname;
    private String content;
    private String sign;
    private String scene;
    private String alias;
    private String bigheadimgurl;
    private String smallheadimgurl;
    private String opcode;
    /// 来源，可以做邀请统计、营销用
    /// </summary>
    private String sourceUserName;
    private String sourceNickName;
    /// 原始内容，可以自行解析
    private String rawContent;
    private Date addTime;
    private boolean passed;

    public ReceiveVerifyMsgDeal(Map<String, String> params) {
        this.id = Long.parseLong(params.get("Id"));
        this.ticket = params.get("Ticket");
        this.fromUsername = params.get("FromUsername");
        this.encryptUsername = params.get("EncryptUsername");
        this.fromNickname = params.get("FromNickname");
        this.content = params.get("Content");
        this.sign = params.get("Sign");
        this.scene = params.get("Scene");
        this.alias = params.get("Alias");
        this.bigheadimgurl = params.get("Bigheadimgurl");
        this.smallheadimgurl = params.get("Smallheadimgurl");
        this.opcode = params.get("Opcode");
        this.sourceUserName = params.get("SourceUserName");
        this.sourceNickName = params.get("SourceNickName");
        this.rawContent = params.get("RawContent");
        try {
            this.addTime = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse(params.get("AddTime"));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        this.passed = Boolean.parseBoolean(params.get("Passed"));
    }
}
